// Car.cpp

#include "Car.hpp"

Car::Car()
{
	id = 0;
	v = 0;
	vAvg = 0;
	time = 0;
	pathId = 0;
}

Car::Car(int id, int speed, int path,QPoint position)
{
	this->id = id;
	this->v = speed;
	this->vAvg = 0;
	this->time = 0;
	this->pathId = path;
	this->position = position;

}

void Car::accelerate(int amount)
{
	v = v + amount;
}

void Car::brake(int amount)
{
	v = v - amount;
}

void Car::incTime()
{
	time = time + 1;
	vAvg = (vAvg*(time-1) + v)/time;
}

int Car::getAvgSpeed()
{
	return this->vAvg;
}

int Car::getSpeed()
{
	return this->v;
}

void Car::setSpeed(int value)
{
	this->v = value;
}

int Car::getPathId()
{
	return this->pathId;
}

void Car::setPathId(int id)
{
	this->pathId = id;
}

int Car::getTime()
{
	return this->time;
}

int Car::getId()
{
	return this->id;
}

QPoint Car::getPosition()
{
	return this->position;
}

void Car::setPosition(QPoint position)
{
	this->position = position;
}

void Car::setPosition(int x, int y)
{
	this->position.setX(x);
	this->position.setY(y);
}

Car::~Car()
{
}
